import { defineStore } from "pinia"

import { setToken } from "@/utils/setToken"

export const useUserStore = defineStore({
  id: 'user',
  state: () => {
    return {
      userName: 'admin',
      userInfo: {}
    }
  },
  getters: {},
  actions: {
    login(info: { userName: string, password: string }) {
      this.userName = info.userName
      setToken('login')
    },
    logout() {
      this.userName = ''
      setToken('')
    }
  }
})